﻿Imports System.Web.Http
Imports System.Web.Http.Cors

<RoutePrefix("api/Orders")>
Public Class OrdersController
    Inherits ApiController

    <Authorize>
    <Route("")>
    <EnableCors("*", "*", "*")>
    Public Function [Get]() As IHttpActionResult
        Return Ok(Order.CreateOrders())
    End Function
End Class

#Region "Helpers"

Public Class Order
    Public Property OrderID() As Integer
        Get
            Return m_OrderID
        End Get
        Set(value As Integer)
            m_OrderID = Value
        End Set
    End Property

    Private m_OrderID As Integer

    Public Property CustomerName() As String
        Get
            Return m_CustomerName
        End Get
        Set(value As String)
            m_CustomerName = Value
        End Set
    End Property

    Private m_CustomerName As String

    Public Property ShipperCity() As String
        Get
            Return m_ShipperCity
        End Get
        Set(value As String)
            m_ShipperCity = Value
        End Set
    End Property

    Private m_ShipperCity As String

    Public Property IsShipped() As [Boolean]
        Get
            Return m_IsShipped
        End Get
        Set(value As [Boolean])
            m_IsShipped = Value
        End Set
    End Property

    Private m_IsShipped As [Boolean]

    Public Shared Function CreateOrders() As List(Of Order)
        Dim OrderList As New List(Of Order)() From {
            New Order() With {
                .OrderID = 10248,
                .CustomerName = "Taiseer Joudeh",
                .ShipperCity = "Amman",
                .IsShipped = True
            },
            New Order() With {
                .OrderID = 10249,
                .CustomerName = "Ahmad Hasan",
                .ShipperCity = "Dubai",
                .IsShipped = False
            },
            New Order() With {
                .OrderID = 10250,
                .CustomerName = "Tamer Yaser",
                .ShipperCity = "Jeddah",
                .IsShipped = False
            },
            New Order() With {
                .OrderID = 10251,
                .CustomerName = "Lina Majed",
                .ShipperCity = "Abu Dhabi",
                .IsShipped = False
            },
            New Order() With {
                .OrderID = 10252,
                .CustomerName = "Yasmeen Rami",
                .ShipperCity = "Kuwait",
                .IsShipped = True
            }
        }

        Return OrderList
    End Function
End Class

#End Region